import 'package:flutter/material.dart';

class ButtonCustom extends StatelessWidget {
  final String txt;
  final String type;
  final Color color;
  final ShapeBorder shape;
  final VoidCallback onPressed;

  const ButtonCustom(
      [this.txt = '自定义按钮',
        this.color = Colors.blueAccent,
        this.onPressed,
        this.type = 'primary',
        this.shape,
        ])
      : super();

  @override
  Widget build(BuildContext context) {
    final _onPressed = onPressed;
    return FlatButton(
      padding: EdgeInsets.all(20),
      child: RaisedButton(
        child: Text(txt),
        // 外形
        shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(5.0)
        ),
        // 按钮颜色
        // color: color,
        color: color,
        // 阴影
        elevation: 2.0,
        // 按下的阴影
        highlightElevation: 5.0,
        onPressed: () {
          if (_onPressed is VoidCallback) {
            _onPressed();
          }
        },
      ),
    );
  }
}